#include<bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
const int N=4e5+5;
int n,m;
int b[N];
struct node{int x,o;}q[N];
namespace t1{
	struct sgt{int l,r,cnt,sum;}t[N<<2];
	#define l(p) t[p].l
	#define r(p) t[p].r
	#define cnt(p) t[p].cnt
	#define sum(p) t[p].sum
	void build(int p,int l,int r){
		t[p]={l,r,0,0};if(l==r)return;
		int mid=l+r>>1;build(p<<1,l,mid),build(p<<1|1,mid+1,r);
	}
	void ins(int p,int x,int k){
		cnt(p)+=k,sum(p)+=b[x]*k;if(l(p)==r(p))return;
		ins(p<<1|(x>(l(p)+r(p)>>1)),x,k);
	}
	int ct(int p,int l,int r){
		if(l>r||l>n||r<1)return 0;
		if(l<=l(p)&&r(p)<=r)return cnt(p);
		int mid=l(p)+r(p)>>1;
		if(r<=mid)return ct(p<<1,l,r);
		if(l>mid)return ct(p<<1|1,l,r);
		return ct(p<<1,l,r)+ct(p<<1|1,l,r);
	}
	int sm(int p,int l,int r){
		if(l>r||l>n||r<1)return 0;
		if(l<=l(p)&&r(p)<=r)return sum(p);
		int mid=l(p)+r(p)>>1;
		if(r<=mid)return sm(p<<1,l,r);
		if(l>mid)return sm(p<<1|1,l,r);
		return sm(p<<1,l,r)+sm(p<<1|1,l,r);
	}
	int gl(int p,int k){
		if(l(p)==r(p))return l(p);
		return k<=cnt(p<<1)?gl(p<<1,k):gl(p<<1|1,k-cnt(p<<1));
	}
	int gr(int p,int k){
		if(l(p)==r(p))return r(p);
		return k<=cnt(p<<1|1)?gr(p<<1|1,k):gr(p<<1,k-cnt(p<<1|1));
	}
	int fl(int p,int k){
		if(!k)return 0;
		if(l(p)==r(p))return assert(k<=cnt(p)),b[l(p)]*k;
		if(k<=cnt(p<<1))return fl(p<<1,k);
		return fl(p<<1|1,k-cnt(p<<1))+sum(p<<1);
	}
	int fr(int p,int k){
		if(!k)return 0;
		if(l(p)==r(p))return assert(k<=cnt(p)),b[r(p)]*k;
		if(k<=cnt(p<<1|1))return fr(p<<1|1,k);
		return fr(p<<1,k-cnt(p<<1|1))+sum(p<<1|1);
	}
	void dfs(int p){
		if(l(p)==r(p)){
			for(int i=1;i<=cnt(p);i++)cout<<l(p)<<' ';
			return;
		}dfs(p<<1),dfs(p<<1|1);
	}
}
namespace t2{
	struct sgt{int l,r,len,sum[2],tag[2];}t[N<<2];
	#define l(p) t[p].l
	#define r(p) t[p].r
	#define len(p) t[p].len
	#define sum(p,k) t[p].sum[k]
	#define tag(p,k) t[p].tag[k]
	void build(int p,int l,int r){
		l(p)=l,r(p)=r;if(l==r)return;
		int mid=l+r>>1;build(p<<1,l,mid),build(p<<1|1,mid+1,r);
	}
	inline void ch(int p,int k,int o){sum(p,o)+=k*len(p),tag(p,o)+=k;}
	inline void spread(int p,int o){
		if(!tag(p,o))return;
		ch(p<<1,tag(p,o),o),ch(p<<1|1,tag(p,o),o),tag(p,o)=0;
	}
	void ins(int p,int x,int k){
		if(l(p)==r(p)){
			len(p)+=k;
			if(k==1)sum(p,0)=t1::sm(1,1,x),sum(p,1)=t1::sm(1,x,n);
			else sum(p,0)=sum(p,1)=0;return;
		}spread(p,0),spread(p,1);
		ins(p<<1|(x>l(p)+r(p)>>1),x,k),len(p)=len(p<<1)+len(p<<1|1);
		for(int i=0;i<2;i++)sum(p,i)=sum(p<<1,i)+sum(p<<1|1,i);
	}
	void add(int p,int l,int r,int k,int o){
		if(l<=l(p)&&r(p)<=r)return ch(p,k,o);
		spread(p,o);int mid=l(p)+r(p)>>1;
		if(l<=mid)add(p<<1,l,r,k,o);
		if(r>mid)add(p<<1|1,l,r,k,o);
		sum(p,o)=sum(p<<1,o)+sum(p<<1|1,o);
	}
	int ask(int p,int l,int r,int o){
		if(l>r||l>n||r<1)return 0;
		if(l<=l(p)&&r(p)<=r)return sum(p,o);
		spread(p,o);int mid=l(p)+r(p)>>1;
		if(r<=mid)return ask(p<<1,l,r,o);
		if(l>mid)return ask(p<<1|1,l,r,o);
		return ask(p<<1,l,r,o)+ask(p<<1|1,l,r,o);
	}
	inline int smn(int k){
		return k?ask(1,1,t1::gl(1,k),0):0;
	}
	inline int smx(int k){
		return k?ask(1,t1::gr(1,k),n,1):0;
	}
	inline int mn(int l,int r){return l<=r?smn(r)-smn(l-1):0;}
	inline int mx(int l,int r){return l<=r?smx(r)-smx(l-1):0;}
	inline void mdf(int x,int k){
		add(1,x,n,k*b[x],0),add(1,1,x,k*b[x],1),ins(1,x,k);
	}
}
signed main(){
	freopen("kte.in","r",stdin);
	freopen("kte.out","w",stdout);
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>m;set<int>s;
	for(int i=1;i<=m;i++){
		int x;cin>>x;
		if(s.find(x)!=s.end())q[i]={x,-1},s.erase(x);
		else q[i]={x,1},s.insert(x);b[++n]=x;
	}sort(b+1,b+n+1),n=unique(b+1,b+n+1)-b-1;
	t1::build(1,1,n),t2::build(1,1,n);
	int len=0;
	for(int i=1;i<=m;i++){
		int x=lower_bound(b+1,b+n+1,q[i].x)-b,o=q[i].o;
		t1::ins(1,x,o),t2::mdf(x,o),len+=o;
		int l=1,r=len/2,p1=1,p2=0;
		while(l<=r){
			int mid=l+r>>1;
			if(t1::fl(1,mid)>t1::fr(1,mid-1))l=mid+1,p1=mid;
			else r=mid-1;
		}
		int ans=0;
		ans+=t2::mx(1,p1-1)-t2::mn(1,p1-1);
		l=p1+1,r=len;
		while(l<=r){
			int mid=l+r>>1;
			if(t1::fl(1,mid)>t1::fr(1,mid-1))r=mid-1,p2=mid;
			else l=mid+1;
		}
		if(p2){
			ans+=t2::mx(p2,len)-t2::mn(p2,len);
			if(p1<=p2-1)ans+=t1::fr(1,p2-1)-t1::fl(1,p1);
		}else if(p1<=len)ans+=t1::fr(1,len)-t1::fl(1,p1);
		cout<<ans<<endl;
	}
	return 0;
}